<?php
error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
require_once('./roots.php');
require_once($root_path.'include/inc_environment_global.php');
/**
* CARE2X Integrated Hospital Information System Deployment 2.2 - 2006-07-10
* GNU General Public License
* Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla
* elpidio@care2x.org, 
*
* See the file "copy_notice.txt" for the licence notice
*/
define('LANG_FILE','editor.php');
$local_user='ck_cafenews_user';
require_once($root_path.'include/inc_front_chain_lang.php');

if(isset($groupopt)) {
    switch($groupopt)
    {
	    case 'newgroup':	   header('Location: cafenews-edit-price-newgroup.php'.URL_REDIRECT_APPEND);
		                                break;
        case 'set_currency':  header('Location: cafenews-edit-price-currency-set.php'.URL_REDIRECT_APPEND);
		                                break;
	    default:                    header('Location: cafenews-edit-price.php'.URL_REDIRECT_APPEND.'&groupname='.$groupopt);break; 
    }
}

$breakfile='cafenews.php'.URL_APPEND;
$returnfile='cafenews-edit-select.php'.URL_APPEND;

$dbtable='care_cafe_prices';

$sql="SELECT article FROM $dbtable WHERE description='group'";

if(defined('LANG_DEPENDENT') && (LANG_DEPENDENT==1)){
	$sql.="' AND lang='".$lang."'";
}
			
if($ergebnis=$db->Execute($sql)){
	$rows=$ergebnis->RecordCount();
}else{
	echo "<p>".$sql."<p>$LDDbNoRead";
}

?>
<?php html_rtl($lang); ?>
<!-- Generated by AceHTML Freeware http://freeware.acehtml.com -->
<!-- Creation date: 21.12.2001 -->
<head>
<?php echo setCharSet(); ?>
<title></title>

<?php if($rows) : ?>
<script language="javascript">
function chkForm(d)
{
	var opt=<?php echo $rows+3 ?>;
	if(opt==2)
	{
		if((d.groupopt[0].checked)||(d.groupopt[1].checked)) return true;
		else return false;
	}
	else
	{
		for(i=0;i<opt;i++)
		{
			if(d.groupopt[i].checked) return true;
		}
		return false;
	}
}
</script>
<?php endif; ?>

<?php if($cfg['dhtml']) include($root_path."include/inc_css_a_hilitebu.php"); ?>

<SCRIPT LANGUAGE="javascript" >
function chkRadioButton(e){
	if(e) e.checked=true;
}
</SCRIPT>

<?php require($root_path.'include/inc_css_a_hilitebu.php'); ?>

</head>
<body>
<FONT  SIZE=8 COLOR="#cc6600">
<a href="javascript:editcafe()"><img <?php echo createComIcon($root_path,'basket.gif','0') ?>></a> <b><?php echo $LDCafePrices ?></b></FONT>
<hr>
<form name="selectform" action="cafenews-edit-price-select.php" <?php if($rows) echo 'onSubmit="return chkForm(this)"'; ?>>
<table border=0>
  <tr>
    <td><img <?php echo createMascot($root_path,'mascot1_r.gif','0') ?>></td>
    <td colspan=2><FONT  SIZE=4 COLOR="#000066">
<?php if ($rows) : ?>
			<?php echo $LDMarkGroup; ?>
<?php else : ?>
			<?php echo $LDCreateGroupPrompt; ?>
<?php endif ;?>
	</td>
  </tr>
<?php if($rows)
{
	echo '
  <tr>
    <td>&nbsp;</td>
    <td bgcolor="ccffff" colspan=2><p><br>';
	for($i=0;$i<$rows;$i++)
	{
		$ginfo=$ergebnis->FetchRow();
		echo '
		<input type="radio" name="groupopt" value="'.$ginfo['article'].'"> 
		<a href="#" onClick="document.selectform.groupopt['.$i.'].checked=true"> '.$ginfo['article'].'</a><br>';
	}
	echo '
  <p></td>
  </tr>
  <tr>
    <td >&nbsp;</td>
    <td colspan=2><FONT  SIZE=4 COLOR="#000066">'.$LDOr.'...</td>
  </tr>
	';
}
 ?>

    <td>&nbsp;</td>
    <td bgcolor="ccffff" colspan=2><p><br>
		<input type="radio" name="groupopt" value="newgroup" <?php if (!$rows) echo "checked"; ?>> 
		<a href="#" <?php 
			if(!$rows) $i=0;
			echo 'onClick="document.selectform.groupopt['.$i.'].checked=true"';
			?>><?php echo $LDCreateGroup ?></a><br><p>
  </td>
  </tr>
  <tr>
    <td >&nbsp;</td>
    <td colspan=2><FONT  SIZE=4 COLOR="#000066"><?php echo $LDOr ?>...</td>
  </tr>
    <td>&nbsp;</td>
    <td bgcolor="ccffff" colspan=2><p><br>
		<input type="radio" name="groupopt" value="set_currency" <?php if (!$rows) echo "checked"; ?>> 
 		<a href="#" <?php 
		if(!$rows) $i=1; else $i++;
		echo 'onClick="document.selectform.groupopt['.$i.'].checked=true"';
		?>><?php echo $LDSetCurrency ?></a>
 		<p>
 </td>
  </tr>
  <tr>
    <td>
	<a href="<?php echo $returnfile ?>"><img <?php echo createLDImgSrc($root_path,'back2.gif','0') ?>></a>
	</td>
    <td >
<input type="image" <?php echo createLDImgSrc($root_path,'continue.gif','0') ?>>
  </td>
    <td>
	<a href="<?php echo $breakfile ?>"><img <?php echo createLDImgSrc($root_path,'cancel.gif','0') ?>></a>
  </td>
  </tr>
  
</table>
<input type="hidden" name="sid" value="<?php echo $sid ?>">
<input type="hidden" name="lang" value="<?php echo $lang ?>">
</form></body>
</html>
